package com.zb.hms.base.util.validationUtil.constraintValidation;

import java.util.regex.Pattern;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import com.zb.hms.base.util.stringUtil.RegexConstants;
import com.zb.hms.base.util.validationUtil.constraint.Name;
/**
 * 
 * Name注解的实现
 * 新版本的说明，多个新版本依次换行说明
 * @author zb
 * @date : 2017年8月24日 下午6:50:39
 * @version V1.0
 * @since JDK 1.8
 */
public class NameValidator implements  ConstraintValidator<Name, CharSequence > {
	private static final String ISNAME= RegexConstants.ISNAME;
	@Override
	public void initialize(Name constraintAnnotation) {
		// TODO Auto-generated method stub	
	}

	@Override
	public boolean isValid(CharSequence value, ConstraintValidatorContext context) {
		// TODO Auto-generated method stub		
		if ( value == null || value.length() == 0 ) {
			return true;
		}		
		if(Pattern.matches(ISNAME, value))
			return true;		
		 return false;
	}
}
